home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / GraphicsWrap / Source / TGIFCell.m < prev   
Text File  |  1991-09-16  |  2KB  |  106 lines

  1. #import "TGIFCell.h"
  2. #import "TGIF.h"
  3. #import "ListCell.h"
  4. #import "miscutil.h"
  5. #import <appkit/Font.h>
  6. #import <appkit/SelectionCell.h>
  7. #import <appkit/Text.h>
  8. #import <appkit/View.h>
  9. #import <appkit/graphics.h>
  10. #import <dpsclient/psops.h>
  11. #import <string.h>
  12.  
  13. extern void free();
  14.  
  15. @implementation TGIFCell : ListCell
  16.  
  17. -init
  18. {
  19.   [super init];
  20.   number1=-1;
  21.   number2=-1;
  22.   number3=-1;
  23.   return self;
  24. }
  25.  
  26. -(char *)emitCmd
  27. {
  28.    char cmd[100];
  29.   char tmp[30];
  30.   strcpy(cmd, command);
  31.   if(number1!=-1){
  32.     sprintf(tmp, " %d", number1);
  33.     strcat(cmd, tmp);
  34.   }
  35.   if(number2!=-1){
  36.     sprintf(tmp, " %d", number2);
  37.     strcat(cmd, tmp);
  38.   }
  39.   if(number3!=-1){
  40.     strcat(cmd, tmp);
  41.     sprintf(tmp, " %d", number3);
  42.   }
  43.   strcat(cmd, "\n");
  44.    return cmd;
  45. }
  46.  
  47. - free
  48. {
  49.   // since command isn't mallocced, but assigned, we don't have to free()
  50.   //  free(command);
  51.   return [super free];
  52. }
  53.  
  54. #define FIRST_COLUMN_START 5.0
  55. #define SECOND_COLUMN_START (FIRST_COLUMN_START+70)
  56. #define THIRD_COLUMN_START (SECOND_COLUMN_START+30)
  57. #define FOURTH_COLUMN_START (THIRD_COLUMN_START+30)
  58.  
  59. - drawInside:(const NXRect *)cellFrame inView:controlView
  60. {
  61.   char hitInfo[200];
  62.   /* set the font according to our drawing status */
  63.   if (NXDrawingStatus != NX_DRAWING) {
  64.     [support set];
  65.   } else {
  66.     [[support screenFont] set];
  67.   }
  68.   
  69.   /* erase the cell */
  70.   PSsetgray((cFlags1.state || cFlags1.highlighted) ? NX_WHITE : NX_LTGRAY);
  71.   NXRectFill(cellFrame);
  72.   
  73.   PSsetgray(NX_BLACK);
  74.   PSmoveto(NX_X(cellFrame) + FIRST_COLUMN_START,
  75.        NX_Y(cellFrame) + lineHeight - descender);
  76.   PSshow(command);
  77.   
  78.   /* draw the number of hits */
  79.   if(number1!=-1){
  80.     sprintf(hitInfo, "%d", number1);
  81.     PSmoveto(NX_X(cellFrame) + SECOND_COLUMN_START,
  82.          NX_Y(cellFrame) + lineHeight - descender);
  83.     PSshow(hitInfo);
  84.   }
  85.  
  86.   if(number2!=-1){
  87.     sprintf(hitInfo, "%d", number2);
  88.     PSmoveto(NX_X(cellFrame) + THIRD_COLUMN_START,
  89.          NX_Y(cellFrame) + lineHeight - descender);
  90.     PSshow(hitInfo);
  91.   }
  92.  
  93.   if(number3!=-1){
  94.     sprintf(hitInfo, "%d", number3);
  95.     PSmoveto(NX_X(cellFrame) + FOURTH_COLUMN_START,
  96.          NX_Y(cellFrame) + lineHeight - descender);
  97.     PSshow(hitInfo);
  98.   }
  99.  
  100.   // draw the cell generic stuff
  101.   [super drawInside:(const NXRect *)cellFrame inView:controlView];
  102.   return self;
  103. }
  104.  
  105. @end
  106.